package com.lcz.cloud_note.controller;

import com.lcz.cloud_note.entity.Book;
import com.lcz.cloud_note.service.BookService;
import com.lcz.cloud_note.util.NoteResult;
import com.lcz.cloud_note.util.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 笔记本
 */
@RestController
@RequestMapping("/book")
public class BookController
{
    @Resource
    private BookService bookService;


    /**
     * 添加笔记
     */
    @RequestMapping("/add.do")
    public NoteResult<Book> add(String userId, String title){
        NoteResult<Book> result = bookService.addBook(userId, title);
        return result;
    }
    /**
     * 加载笔记
     */
    @RequestMapping("/loadBooks.do")
    public NoteResult<List<Book>> loadBooks(String userId){
        NoteResult<List<Book>> result = bookService.loadUserBook(userId);
        return result;
    }

    @RequestMapping("/update.do")
    public Result update(String bookId, String title){
        return bookService.updateBook(bookId,title);
    }

}
